home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus Special 23
/
AMIGAplus Sonderheft 23 (2000)(Falke)(DE)[!].iso
/
Updates
/
Librarys
/
MMULib
/
Autodocs
/
memory.doc
< prev
next >
Wrap
Text File
|
1999-11-19
|
15KB
|
489 lines
TABLE OF CONTENTS
memory.library/--Background--
memory.library/CreateAdrSpace
memory.library/DeleteAdrSpace
memory.library/AllocVMPool
memory.library/DeleteVMPool
memory.library/AttachTask
memory.library/DetachTask
memory.library/AllocVMVec
memory.library/FreeVMVec
memory.library/LockVMVec
memory.library/UnlockVMVec
memory.library/--Background-- memory.library/--Background--
PURPOSE
The memory.library provides functions for memory allocation and
deallocation that are superior to those of the exec.library.
The functions of this library will provide so called "virtual memory"
by using the mmu.library, memory that can be swapped to disk
transparently to the application. Hence, applications will be usually
able to allocate more memory than physically available.
Certain access restrictions arise for memory allocated by the
memory.library. First, you can't access it in Forbid() or Disable()
state. Second, it can't be shared amongst different pools. You
must explicitly attach the tasks that should be able to access memory
from a given pool. Thus, you can't use this kind of memory for keeping
Os structures since they may be passed to different tasks for further
processing. Third, you MAY NOT access virtual memory in a situation
where file I/O would be impossible. That is, DO NOT access this mem
while:
- holding a lock on the dos.library handler lists
- disabling the filing system of the swap partition
- making the swapping exec.device unaccessible
- taking over the hardware
The mmu.library will try to detect such situations and will throw
a guru if that's possible. However, if it is not, these situations
will result in a dead-lock! Keep care!
This restriction can be somewhat weakened by the LockVMVec/UnlockVMVec
functions. By calling these functions, you can lock a given memory
vector in memory and hence, will be able access it WITHIN Forbid().
It returns a pointer to the physical location of that memory block
which must be used if that memory is passed to a different task or
other hardware components.
This kind of "virtual memory" is of course some kind of a
"poor man's solution" for implementing virtual memory. No exec
function will be patched and old programs will continue to work
without any change. The library is of course of limited or no use
at all for old programs since it doesn't redirect standard memory
allocation functions to their "virtual" counterparts. Thus, this
is a very "conservative" approach to overcome this limitation of
AmigaOs.
A special "VMM/GigaMem" patch might be made available that uses
the functions of this library to provide virtual memory to every
task. However, since this CAN'T be fully compatible to old programs
and may, therefore, cause some compatibility problems. It should be
up to the user if she/he likes to install a patch like this or not,
but it should NOT the way how virtual memory enters AmigaOs, at
least not now.
The basic objects the memory.library handles is first the
"AddressSpace" object. It defines - as it says - an common
address space for the tasks attachted to it. It is the memory.library
implementation of the mmu.library "context". Each address space can
be linked to as many tasks as you wish, but a task can be attached
to only one address space at a time.
The actual memory allocation is done from "VMPools". They are the
memory.library counterpart of the exec "memory pools". Each address
space may contain as many "VMPools" as you wish, but only tasks
attachted to the address space of the pool can use it.
memory.library/CreateAdrSpace memory.library/CreateAdrSpace
NAME
CreateAdrSpace - create a new address space.
SYNOPSIS
BOOL CreateAdrSpace( );
d0
BOOL CreateAdrSpace( VOID );
FUNCTION
Build a new address space and attach the calling task to this
address space.
INPUTS
none.
RETURNS
a true/false boolean success indicator.
NOTES
This call will build a new mmu.library "Context" for the calling
task and will enter this context for this task. The task calling
this function should not be attachted to any other address space
or this task will fail. A task can be attached to one address
space at a time only.
This call will change the tc_Switch() and tc_Launch() function
pointers of the calling task.
SEE ALSO
DeleteAdrSpace(), exec/tasks.h
memory.library/DeleteAdrSpace memory.library/DeleteAdrSpace
NAME
DeleteAdrSpace - delete an address space.
SYNOPSIS
DeleteAdrSpace( );
DeleteAdrSpace( void );
FUNCTION
This call deletes the address space of the calling task. It will
leave the private context build for this address space and will
enter the global context.
INPUTS
none.
RETURNS
nothing.
NOTES
This call uses the CurrentContext() call of the mmu.library and
deletes this context. The task is then re-attachted to the global
common context. No virtual memory must be used at that time, nor
any other task may be attachted to this address space.
It is safe to call this function if the calling task isn't attached
to any address space. Nothing will happen in this case.
SEE ALSO
CreateAdrSpace(), mmu.library/CurrentContext()
memory.library/AllocVMPool memory.library/AllocVMPool
NAME
AllocVMPool - create a pool of virtual memory.
SYNOPSIS
pool = AllocVMPool( reqments, attributes );
d0 d0 d1
VMPool * AllocVMPool( ULONG, ULONG );
FUNCTION
Creates a memory pool for virtual memory and adds the calling task
to the list of tasks that can safely use this pool.
INPUTS
reqments - an exec style memory attributes flags field.
This defines the memory type the pool will be taken from,
not ANY implications about the logical addresses asssigned
to the memory allocated from that pool. Thus, if you call
LockVMVec() later on, that vector will be mapped to the
memory described by the reqments above.
The following bits, defined in exec/memory.h will be
ignored:
MEMF_PUBLIC - as the pool is always private in
this sense.
MEMF_CLEAR - as this flag must be specified
individually when allocating memory from the pool.
attributes - special attribute flags.
VMEMF_PRIVATE - make the memory in the pool invalid
to other tasks.
VMEMF_PROTECT - protect the underlying MMU context.
VMEMF_NONCACHE - mark the memory in the pool
explicitly as noncacheable
(defaults to the cache type of the physical memory)
VMEMF_PRECISE - mark the memory in the pool as
requiring the precise exception model.
(only for special MMUs, not available in general)
Implies VMEMF_NONCACHE
VMEMF_SERIALIZED- mark the memory as serialized non-
cacheable.
(only for special MMUs, not available in general).
RETURNS
A handle to the pool or NULL in case of failure. The calling
task will be prepared to use the memory in the pool.
NOTES
To use this call, a private address context must have been
build before.
SEE ALSO
CreateAdrSpace(), DeleteVMPool(), exec/memory.h
memory.library/DeleteVMPool memory.library/DeleteVMPool
NAME
DeleteVMPool - Delete a virtual memory pool.
SYNOPSIS
result = DeleteVMPool( pool);
d0 a0
BOOL DeleteVMPool (VMPool *);
FUNCTION
Deletes the given virtual memory pool in question, releases the
memory occupied by the pool and the release the used space on disk.
INPUTS
pool - a handle to a VMPool as created by AllocVMPool.
Passing in NULL is safe.
RESULTS
A boolean that indicates whether some memory in the pool is
still allocated. Can be usually ignored but is useful for
debugging.
NOTES
SEE ALSO
AllocVMPool()
memory.library/AttachTask memory.library/AttachTask
NAME
AttachTask - attach a task to the address space of the calling task.
SYNOPSIS
result = AttachTask( task);
d0 a1
BOOL AttachTask(struct Task *);
FUNCTION
To allow another task sharing the same address space than the calling
task, this new task must be attached to the common address space
with this call.